import greenfoot.*;  

/**
 * Big sandbag, disappears slow but explodes when hit the ground after the airplane dropped it.
 * The player actor should catch this type of sandbag
 * 
 * @author Jasper Jans
 */
public class BigBag extends Sandbag
{
    private int explodingImage = 0;
    
    public void act() 
    {
        super.act();
        
        if(explodingImage > 0)
            setExplosionImage();
    }    
    
    public BigBag()
    {
        super.sandFilling = 5000;
        super.caughtImageFile = "sandbag-small_x2.png";
        super.caughtImageFileBlink = "sandbag-small_x2_blink.png";
        super.dropSound = "sandbags-bigbag.mp3";
    }

    /*
     * Initiates explosion sequence
     */
    private void explode()
    {
        explodingImage = 1;
    }
    
    private void setExplosionImage()
    {
        GreenfootImage img = new GreenfootImage("images/explosion/explosion" + Integer.toString(explodingImage) + ".png" );
        setImage(img);
        explodingImage++;
        
        if(explodingImage > 16) 
            getWorld().removeObject(this);
    }
    
    /*
     * Stops dropping and calls explode if not catched in time 
     */
    public void stopDropping()
    {
             super.allowPickUp = false;
             
             explode();
             
             super.stopDropping();
    }
    
    /*
     * Add 75 points
     */
    protected void addScore()
    {
        ((MiniGame)getWorld()).addScore(75);
    }
}
